package com.jevons.geo_edit.activity;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.widget.Toolbar;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.lifecycle.ViewModel;

import com.jevons.geo_edit.R;
import com.jevons.muffin.activity.BaseActivity;
import com.jevons.muffin.utilcode.StringUtils;
import com.jevons.muffin.vm.BasePresenter;
import com.trello.rxlifecycle3.LifecycleTransformer;

/**
 * Copyright 2020 JxGIS
 *
 * @file BaseBindingActivity
 * @auth linaisheng
 * Created on 2024/5/16.
 * Description：
 */
public abstract class BaseBindingActivity<
        V extends ViewDataBinding, VM extends ViewModel, P extends BasePresenter> extends BaseActivity<P> {

    protected V dataBinding;

    protected VM viewModel;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        dataBinding = DataBindingUtil.setContentView(
                this, setLayout());
        dataBinding.setLifecycleOwner(this);

        initView(savedInstanceState);
    }


    protected abstract int setLayout();


    protected abstract Class<VM> getViewModelClz();

    @Override
    protected VM initViewModel() {
        Class<VM> clz = getViewModelClz();
        if (clz != null) {
            viewModel = (VM) getViewModel(getViewModelClz());
            return viewModel;
        }
        return null;
    }

    protected abstract void initView(Bundle savedInstanceState);


}